// SPDX-License-Identifier: GPL-2.0-or-later
/* Driver for Virtio QTBox device.
 *
 * Copyright 2022 HUAWEI TECHNOLOGIES CO., LTD.
 */

#ifndef _LINUX_UAPI_VIRTIO_QTBOX_SANDBOX_H
#define _LINUX_UAPI_VIRTIO_QTBOX_SANDBOX_H

#define VQTBOX_IOCTL	0xAE

struct vqtbox_sandbox_vm_cap {
	uint64_t	max_instances;
	uint64_t	max_vcpus_per_inst;
	uint64_t	max_mem_regions_per_inst;
	uint64_t	max_pdevs_per_inst;
	uint64_t	mem_addr_align;
	uint64_t	mem_size_align;
#define VQTBOX_SANDBOX_VM_QUIET_MODE	(1 << 0)
#define VQTBOX_SANDBOX_VM_DEBUG_MODE	(1 << 1)
	uint64_t	supported_launch_mode;
#define VQTBOX_SANDBOX_VM_EIF_FORMAT	(1 << 0)
	uint64_t	supported_image_format;
	uint64_t	image_offset;
};

struct vqtbox_sandbox_define {
	uint64_t	launch_mode;
	uint64_t	image_format;
	/* to user */
	uint64_t	sid;
};

struct vqtbox_sandbox_mem_range {
	uint64_t	start;
	uint64_t	len;
};

struct vqtbox_sandbox_start {
	uint64_t	cid; /* vsock cid */
};

#define VQTBOX_SANDBOX_GET_CAP	_IOR(VQTBOX_IOCTL, 0x1, struct vqtbox_sandbox_vm_cap)
#define VQTBOX_SANDBOX_DEFINE	_IOR(VQTBOX_IOCTL, 0x2, struct vqtbox_sandbox_define)
#define VQTBOX_SANDBOX_ADD_CPU	_IOR(VQTBOX_IOCTL, 0x3, uint64_t)
#define VQTBOX_SANDBOX_ADD_MEM	_IOR(VQTBOX_IOCTL, 0x4, struct vqtbox_sandbox_mem_range)
#define VQTBOX_SANDBOX_START	_IOR(VQTBOX_IOCTL, 0x5, struct vqtbox_sandbox_start)

#endif
